@extends('layouts.header')
@section('content')
    <article class="page-container">
        <form class="form form-horizontal" id="form" autocomplete="off">
            <div class="row cl">
                <label class="form-label col-sm-3">检测项目名称：</label>
                <label class="form-label col-sm-9" style="text-align: left;"> {{ $info->name }}</label>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">备注：</label>
                <label class="form-label col-sm-9" style="text-align: left;"> {{ $info->remark }}</label>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">状态：</label>
                <div class="formControls col-sm-9">
                    <div class="skin-minimal">
                        <div class="radio-box">
                            <label><input type="radio" value="0" name="ishide" @if ($info->ishide==0) checked @endif >显示</label>
                        </div>
                        <div class="radio-box">
                            <label><input type="radio" value="1" name="ishide" @if ($info->ishide==1) checked @endif>隐藏</label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">原始记录填写环境信息：</label>
                <div class="formControls col-sm-9">
                    <div class="skin-minimal">
                        <div class="radio-box">
                            <label><input type="radio" value="1" name="env" @if (data_get($info,'env',1) == 1) checked @endif>填写</label>
                        </div>
                        <div class="radio-box">
                            <label><input type="radio" value="0" name="env" @if (data_get($info,'env',1) == 0) checked @endif >不填</label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">默认合格：</label>
                <div class="formControls col-sm-9">
                    <div class="skin-minimal">
                        <div class="radio-box">
                            <label><input type="radio" value="1" name="pass" @if (data_get($info,'pass',0)==1) checked @endif>是</label>
                        </div>
                        <div class="radio-box">
                            <label><input type="radio" value="0" name="pass" @if (data_get($info,'pass',0)==0) checked @endif >否</label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">试验数据上传对照项目：</label>
                <div class="formControls col-sm-9">
                    <select name="id_map" class="select2">
                        <option value="0">==请选择==</option>
                        @foreach($items as $id => $name)
                        <option value="{{$id}}" @if(data_get($info,'id_map',0)==$id) selected @endif>{{$name}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            @csrf

            <div class="row cl pt-20">
                <div class="col-sm-9 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    <input class="btn btn-danger radius ml-15" type="button" value="&nbsp;&nbsp;取消&nbsp;&nbsp;" onclick="layer_close();">
                </div>
            </div>
        </form>
    </article>

    <script type="text/javascript">
        $(function(){

            var index2;

            $('.skin-minimal input').iCheck({
                checkboxClass: 'icheckbox-blue',
                radioClass: 'iradio-blue',
                increaseArea: '20%'
            });
            
            $("#form").validate({
                rules:{
                    // val:{
                    //     required:true,
                    //     notSpace:true,
                    // },
                    // sort:{
                    //     required:true,
                    // },
                },
                // onkeyup:false,
                // focusCleanup:false,
                success:"valid",
                submitHandler:function(form){
                   $(form).ajaxSubmit({ 
                        type: 'post', 
                        url: "",//自己提交给自己可以不写url   
                        //beforeSend  beforeSubmit
                        
                        beforeSend : function () { 
                            //0.4透明度 白色遮罩
                           index2 = layer.load(2,{ shade: [0.3,'#fff'] }); 
                        },
                        complete : function () { 
                            layer.close(index2); 
                        },
                        success: function(data) {
                            //判断修改结果 
                            if(data === '1'){ 
                                // parent.window.location.reload();//刷新
                                parent.table_reload(0);//0停留在当前页，1回到第一页
                                parent.parent.layer.msg('修改成功!', { icon: 1, time:2000 });
                                layer_close();//关闭自己
                            }else if(data === '2'){ 
                                layer.msg('已存在相同的记录!',{ icon: 2, time:5000 });
                            }else{
                                layer.msg('操作失败!', { icon: 2, time: 2000 }); 
                            } 
                        }, 
                        error: function(data) {
                            ajax_error(data);
                        }
                    }); 
                }
            });
        });


    </script>
@endsection